#include <bits/stdc++.h>
using namespace std;
const int maxn = 100+10;
char m[maxn][maxn];
int M, N;

bool in(int r, int c){
    return r>=0 && r<M && c>=0 &&c<N;
}

int dr[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dc[] = {1, -1, 0, -1, 1, 0, 1, -1};

void dfs(int r, int c){
    m[r][c] = '*';
    for (int i = 0; i < 8; ++i) {
        int tr = r + dr[i], tc = c + dc[i];
        if (in(tr, tc) && m[tr][tc] == '@') dfs(tr, tc);
    }
}

int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    while(cin >> M >> N && M && N){
        for (int r = 0; r < M; ++r) {
            for (int c = 0; c < N; ++c) {
                cin >> m[r][c];
            }
        }
        int ans = 0;
        for (int r = 0; r < M; ++r) {
            for (int c = 0; c < N; ++c) {
                if(m[r][c] == '@'){
                    ++ans;
                    dfs(r, c);
                }
            }
        }
        cout << ans << "\n";
    }
    return 0;
}